package com.teamall.web.sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.teamall.core.common.Page;
import com.teamall.framework.exception.BaseAppException;
import com.teamall.framework.log.LogManager;
import com.teamall.web.sys.db.po.AidStaffPO;
import com.teamall.web.sys.service.IAidStaffService;

/**
 * <Description>aidstaff管理 <br>
 * 
 * @author codeCreater <br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2014年11月11日 <br>
 * @since V1.0<br>
 * @see com.teamall.web.sys.controller <br>
 */

@Controller
@RequestMapping("/subsystem/sys/aidstaff")
public class AidStaffController {

    private static final LogManager logger = LogManager
            .getLogger(AidStaffController.class);

    @Autowired
    private IAidStaffService aidStaffService;

    @RequestMapping("index")
    public String index(Model model) {
        // ///////
        // TODO 根据业务场景，进行条件分支跳转、设置页面默认值等

        // ///////

        return "subsystem/sys/jsp/aidStaff";
    }

    @RequestMapping("queryRecordByPage")
    @ResponseBody
    public Page<AidStaffPO> queryRecordByPage(AidStaffPO record,
            Page<AidStaffPO> resultPage) throws BaseAppException {
        resultPage = aidStaffService.selectByArgAndPage(record, resultPage);
        return resultPage;
    }

    @RequestMapping("add")
    @ResponseBody
    public AidStaffPO add(AidStaffPO record) throws BaseAppException {
        logger.debug("add record begin...record=[{0}]", record);
        aidStaffService.add(record);
        return record;
    }

    @RequestMapping("update")
    @ResponseBody
    public AidStaffPO update(AidStaffPO record) throws BaseAppException {
        logger.debug("modify record begin...record=[{0}]", record);
        aidStaffService.update(record);
        return record;
    }

    @RequestMapping("delete")
    @ResponseBody
    public int delete(AidStaffPO record) throws BaseAppException {
        logger.debug("delete record begin...record=[{0}]", record);
        return aidStaffService.delete(record);
    }

    @RequestMapping("qryRecordInfo")
    @ResponseBody
    public AidStaffPO qryRecordInfo(@RequestParam(value = "staffId",
            required = true) Integer staffId) throws BaseAppException {
        AidStaffPO record = aidStaffService.selectByPrimaryKey(staffId);
        return record;
    }

}
